240

|

6 Applications and Methods in Biosignal Processing

%calculate trigger point 2

tp_angle_2 = (idx_angle_first(1,3)+idx_angle_last(1,2))/2;

%calculate time adjustment for synchronization

st_1 = tp_force_1 - tp_angle_1;

st_2 = tp_force_2 - tp_angle_2;

synchronization_time = (st_1+st_2)/2;

adj_time = time_angle + synchronization_time;

%finding index of time in force and angle closest to trigger points

[¬,idx_f1]=min(abs(time_force-tp_force_1));

[¬,idx_f2]=min(abs(time_force-tp_force_2));

[¬,idx_a1]=min(abs(time_angle-tp_angle_1));

[¬,idx_a2]=min(abs(time_angle-tp_angle_2));

%plot trigger points

subplot(6,1,5)

plot(time_force, value_force,'k-')

hold on

yyaxis right

plot(time_angle, value_angle,'k:')

ylabel('Angle \alpha/deg', 'Color','k')

ax = gca;

ax.YColor = 'k';

axis([0 10 40 300])

scatter(time_angle([idx_a1 idx_a2]), value_angle([idx_a1 idx_a2]),...

100, 'kv')

yyaxis left

axis([0 10 260 500])

xlabel('Time t/s')

ylabel('Force F/N')

scatter(time_force([idx_f1 idx_f2]), value_force([idx_f1 idx_f2]),...

100, 'k^')

title('Force and Angle data with corresponding trigger points')

legend('Force', 'Force Trigger Point', 'Angle', 'Angle Trigger Point')

%plot synchronized force and angle data

subplot(6,1,6)

plot(time_force(1:601), value_force(1:601), 'k-');

hold on

yyaxis right

plot(adj_time, value_angle, 'k:');